import { observable, action } from 'mobx';
import { ListViewPage,RouteLayout } from 'weaver-mobile-page';
import * as Apis from "../../api/customerApis";

export default class WorkplanListSingleStore {
  comObj = {};
  params = {};
  @observable listTab = [];
  @observable listTabKey = "";
  @observable listTabIndex = "my";
  @observable canEdit = false;
  @observable initResponsed = false;// 是否已经得到初始化数据的响应
  @observable initSuccessed = false;// 初始化数据是否获取成功
  @observable initFailedMsg = "";   // 初始化处理失败的原因

  @action
  doNew = (comObj,params) =>{
    this.comObj = comObj;
    this.params = params;
  }

  @action
  doInit = () =>{
    let params = this.params;
    Apis.getHearderTab({type:"crm_workplan",...params}).then(data => {
      this.doInitCallBack(params,data);
    });
  }

  @action
  doInitCallBack = (params,data) =>{
    this.initResponsed = true;
    this.initSuccessed = true;
    this.listTab = data.tabs;
    this.listTabKey = data.keyParam;
    this.canEdit = data.canEdit;
  }


  @action
  topTabChange = (selectedIndex) =>{
    this.listTabIndex = selectedIndex;
  }

  @action
  doClear = () =>{
    this.initResponsed = false;
    this.initSuccessed = false;
    this.initFailedMsg = "";
    this.listTabIndex = "my";
  }
}